package com.google.code.jtasks.bugzilla;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.google.code.jtasks.adapters.RepositoryMetadata;

/**
 * Stores session data for a task repository accessed by a {@link BugzillaTaskSystemAdapter}. Please note that
 * {@link BugzillaSessionData} instances are immutable. If any of their state changes, a new instance will
 * need to be created and set via {@link RepositoryMetadata#setSessionData(Object)} (for the appropriate
 * {@link RepositoryMetadata} instance).
 */
public class BugzillaSessionData
{
	private final List<String> authCookiesCache;

	/**
	 * Constructs a new {@link BugzillaSessionData} instance.
	 * 
	 * @param authCookiesCache
	 *            the {@link List} of authentication cookies that should be passed to the Bugzilla server on
	 *            every XML-RPC operation
	 */
	public BugzillaSessionData(List<String> authCookiesCache)
	{
		if (authCookiesCache == null)
			throw new IllegalArgumentException("Authentication cookies cache may not be null.");

		this.authCookiesCache = new ArrayList<String>(authCookiesCache);
	}

	/**
	 * Returns the {@link List} of authentication cookies that should be passed to the Bugzilla server on
	 * every XML-RPC operation.
	 * 
	 * @return the {@link List} of authentication cookies that should be passed to the Bugzilla server on
	 *         every XML-RPC operation
	 */
	public List<String> getAuthCookiesCache()
	{
		return Collections.unmodifiableList(authCookiesCache);
	}
}
